Identifying Crossings

Crossings Identified for assessment


The map to the left shows culverts that have been identified and started down the path of assessment. These are ALL points that have been flagged as potential tidal culverts.
NOTE that there’s additional points that exist in the GIS file that had to be removed due to incorrect lat/lons these are listed below (might be blank if all have been fixed! (thanks Karen!).

Currently there are 260 mapped crossing locations of which 3 are duplicates.

The following crossing ID’s are flagged as duplicate:

crossingID
2007
2007
425
425
426
426

The following crossing ID’s are errant points not displayed: Reasons being the Lat/Lon were NA or otherwise Crossing ID #:

crossingID

Culverts Needing Corresponding Workbook

Missing datasheet for desktop and field assessment data

***

These are locations that have no Tidal Crossing Assessment Workbooks associated with them OR the crossing ID field in either the shapefile or the workbooks are non-matching.

Are any of these areas of interest for assessing? The map currently uses the ‘Priority Score’ as size/color .
The table below will can either be copied-pasted or downloaded as an excel file that can be used to reference which crossings need to have a data sheet made up (or perhaps not…).

Potential Crossing Location QA

Put accessibility data here…

Data Needs

Missing Locations

These crossing IDs are missing corresponding GIS points (or are not named the same…)


filenames crossingID
Crosing ID #2004 Requires Low Tide Reading (Revisit).xlsm New Crossing 2004
Culvert0.xlsm 0
Culvert20181.xlsm 20181
Culvert20182.xlsm 20182

Prioritizing Assessments:


From these potential points priorities are mapped out based on proximity to important marsh complexes and partner input.

Priority Score is simply the sum of the number of prioity lists the crossing has fallen on (max of 3)

Data Management/QA/Status

Assessment Status:

---
title: "Tidal Culvert Project/Data Status"
output: 
  flexdashboard::flex_dashboard:
    storyboard: true
    theme: spacelab
    source: embed
---

```{r setup, include=FALSE}

# TODO: Move this code block to script and source in across multiple Rmds

library(flexdashboard)
library(readr)
library(readxl)
library(tidyxl)
library(unpivotr)
library(tidyverse)
library(sf)
library(mapview)
library(tncThemes)
library(plotly)
library(hrbrthemes)
library(leaflet)
library(knitr)
library(crosstalk)
library(htmlwidgets)
library(htmltools)
library(magrittr)

knitr::read_chunk("code/rmdSetup.R") # read code chunks from external files to extend beyond multiple Rmds.
```

```{r directorySetup, message=FALSE, warning=FALSE, include=FALSE, paged.print=FALSE}
```

```{r spatialDataLoad, message=FALSE, warning=FALSE, include=FALSE, paged.print=FALSE}
```

```{r culvertData, message=FALSE, warning=FALSE, paged.print=FALSE}
```

Identifying Crossings {.storyboard}
=========================================

### Crossings Identified for assessment 


```{r message=FALSE, warning=FALSE, paged.print=FALSE}
# Crossings that have been IDed via ArcMap and from partners.
# TODO: Tidal stations - check windy API
# TODO: Add popups and/or labels on hover. 

basemap <- leaflet() %>% 
  addProviderTiles(providers$CartoDB.Positron, group = "Carto DB") %>%
  addProviderTiles(providers$HikeBike.HillShading, options = providerTileOptions(opacity = 0.3), group = "Carto DB") %>% 
  addProviderTiles(providers$Esri.WorldImagery, group = "ESRI Aerials") %>% 
  addMouseCoordinates(style = "basic") %>% 
  addLayersControl(baseGroups = c("Carto DB", "ESRI Aerials"), overlayGroups = c("highlight"), position = "bottomright")

basemap %>% 
  addCircleMarkers(data = LIculvert_GISpts, ~Longitude, ~Latitude, radius = 3, fillOpacity = 0.75, fillColor = as.character(tnc_color("Indigo")), stroke = FALSE) %>% 
  addCircleMarkers(data = LIculvert_GISpts, ~Longitude, ~Latitude, radius = 4, fillOpacity = 1, fillColor = as.character(tnc_color("Red Rock")), stroke = FALSE, group = "highlight") %>% 
  hideGroup("highlight")
 


```

***  
The map to the left shows culverts that have been identified and started down the path of assessment. These are _*ALL*_ points that have been flagged as potential tidal culverts.  
_*NOTE*_ that there's additional points that exist in the GIS file that had to be removed due to incorrect lat/lons these are listed below (might be blank if all have been fixed! (thanks Karen!).   

Currently there are _`r length((LIculvert_GISpts$crossingID))`_ mapped crossing locations of which _`r (length((LIculvert_GISpts$crossingID)) - length(unique(LIculvert_GISpts$crossingID)))`_ are duplicates.


The following crossing ID's are flagged as duplicate:
`r kable(duplicatePts)`

***

The following crossing ID's are errant points not displayed:
Reasons being the Lat/Lon were NA or otherwise 
Crossing ID #:
`r kable(errorPts)`


### Culverts Needing Corresponding Workbook
Missing datasheet for desktop and field assessment data

```{r message=FALSE, warning=FALSE, paged.print=FALSE}



map_missingsDataPts <- mapview(LIculvertDataStatus_location %>% filter(missingWorkbook == TRUE), 
                               zcol = 'PriorityScore', 
                               label = as.character(LIculvert_GISpts$crossingID), lwd = .5,
                               cex = 4, legend = TRUE, layer.name = "Culvert by Priority") 
map_missingsDataPts 



#TODO: Bring in the priority info from the "Master Spreadsheet"

```
***

These are locations that have no Tidal Crossing Assessment Workbooks associated with them _OR_ the crossing ID field in either the shapefile or the workbooks are non-matching. 

Are any of these areas of interest for assessing? The map currently uses the 'Priority Score' as size/color .  
The table below will can either be copied-pasted or downloaded as an excel file that can be used to reference which crossings need to have a data sheet made up (or perhaps not...). 



```{r echo=FALSE, message=FALSE, warning=FALSE, paged.print=FALSE}

LIculvert_GISpts %>% 
  st_set_geometry(NULL) %>% 
  as.data.frame() %>% 
  filter(!crossingID %in% LIculvertData$crossingID) %>% 
  dplyr::select(crossingID, TNCPriorit, MarPriorit, PtrPriorit, PriorityScore) %>% 
  DT::datatable(rownames = FALSE, 
              extensions = list('Buttons'), 
              style="bootstrap", width="100%",
              options = list(scrollY=300, 
                             scroller=TRUE,
                             dom = 'Bfrtip',
                             buttons = list('copy', list(extend = 'collection',
                                                         buttons = c('excel'),
                                                         text = 'Download'
                                                         ))
                             )
              )

```


### Potential Crossing Location QA
Put accessibility data here...


Data Needs {.storyboard}
============================================================
### Missing Locations 
These crossing IDs are missing corresponding GIS points (or are not named the same...)

***
```{r message=FALSE, warning=FALSE, paged.print=FALSE}
kable(missingLIculverts)

```

Prioritizing Assessments: {.storyboard}
============================================================

```{r}

map_assessedLItidalCulverts <- mapview(LIculvertData_location, zcol = "PriorityScore", cex = "PriorityScore", na.color = 'red') 
 
marshMap <- mapview(priorityMarshes, zcol = "WETLAND_TY")
map_assessedLItidalCulverts + marshMap
```

***
From these potential points priorities are mapped out based on proximity to important marsh complexes and partner input. 

Priority Score is simply the sum of the number of prioity lists the crossing has fallen on (max of 3)


Data Management/QA/Status
==================================================

### Assessment Status:  

```{r message=FALSE, warning=FALSE, paged.print=FALSE}
#TODO get this Assessed attribute from the culvertStatus file. 
# IDEA: replicate this in the Field/Data mangagement RMd

culvertShared <- SharedData$new(LIculvertDataStatus_location)
# 
# completionMap <- basemap %>% 
#   addCircleMarkers(data = dataStatus_shared, ~Longitude, ~Latitude, radius = 3, fillOpacity = 0.75, fillColor = as.character(tnc_color("Indigo")), stroke = FALSE) %>% 
#   addCircleMarkers(data = dataStatus_shared, ~Longitude, ~Latitude, radius = 4, fillOpacity = 1, fillColor = as.character(tnc_color("Red Rock")), stroke = FALSE, group = "highlight") %>% 
#   hideGroup("highlight")
#  

completionMap <- plot_mapbox(culvertShared, size = ~PriorityScore, color = ~PriorityScore, hoverinfo = "text") %>% 
    highlight(dynamic = TRUE, presistent = TRUE) %>% 
    layout(
    title = "Culvert Locations")
    

completionPlot <- ggplot(culvertShared, aes(x = fieldCompletion, y = DesktopCompletion, fill = fieldAssessed, text = paste("Crossing ID:", crossingID))) + 
  geom_jitter(stroke = 0, size = 2) + 
  theme_ipsum() + 
  coord_flip() + 
  labs(main = "Field Assessed", x = NULL) + 
  scale_fill_viridis_d() + 
  theme(legend.position = "bottom")

completionPlot_gg <-  ggplotly(completionPlot)
completionPlot_gg  <-  layout(completionPlot_gg, dragmode = "pan")


bscols(
  completionMap, 
  ggplotly(completionPlot_gg, tooltip = c("text"), width = 300, height = 300, dynamicTicks = FALSE), widths = c(7,5)
)

# mapview(dataStatus_shared, zcol = "fieldAssessed")
```